/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */

import 'babel-core/polyfill';
import path from 'path';
import express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import Router from './routes';
import proxy from 'express-http-proxy'
import url from 'url'

const server = global.server = express();


server.set('port', (process.env.PORT || 5000));
server.use(express.static(path.join(__dirname, 'public')));

server.use('/*[^\/]+\/api/*', proxy('http://116.228.212.74', {
  forwardPath: (req, res) => {
    return url.parse(req.baseUrl).path + (url.parse(req.url).search || '')
  }
}))

server.listen(server.get('port'), () => {
  /* eslint-disable no-console */
  console.log('The server is running at http://localhost:' + server.get('port'));
  if (process.send) {
    process.send('online');
  }
});
